package com.wanma.panchong;

import java.io.IOException;
import java.util.ArrayList;

import org.apache.tools.ant.taskdefs.optional.extension.LibFileSet;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class TestJsonp {

	public Document getDocument(String url){
		try {
			return Jsoup.connect(url).timeout(5000).get();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null; 
	}
	public static void main(String[] args) {
		TestJsonp t = new TestJsonp();
		Document doc = t.getDocument("http://www.weather.com.cn/weather1d/101210101.shtml#search");
//		Elements elements1 = doc.select("[class=t clearfix]");
//		Elements elements2 = elements1.select("[class=sky skyid lv2 on]");
//		String today = elements2.get(0).text();
//		System.out.println("今日天气： "+today);
//		
//		 //几号
//        Elements elements3 = elements1.select("h1");
//        String number = elements3.get(0).text();
//        System.out.println("日期： "+number);
//
//        // 天气
//        Elements elements4 = elements1.select("[class=wea]");
//        String rain = elements4.get(0).text();
//        System.out.println("天气： "+rain);
//
//        // 最高温度
//        Elements elements5 = elements2.select("span");
//        String highTemperature = elements5.get(0).text()+"°C";
//        System.out.println("最高温："+highTemperature);
//
//        // 最低温度
//        Elements elements6 = elements2.select(".tem i");
//        String lowTemperature = elements6.get(0).text();
//        System.out.println("最低温："+lowTemperature);
//
//        // 风力
//        Elements elements7 = elements2.select(".win i");
//        String wind = elements7.get(0).text();
//        System.out.println("风力："+wind);
		Elements elements1 = doc.select("#today");
		Elements elements2 = elements1.select("[class=xyn-weather-box]");
		Elements elements3 = elements2.select("span");
		System.out.println(elements3.get(0).text());
		ArrayList<Element> elements4 = elements2.select("#select").select("ul").select("li");
		//System.out.println(elements4.get(0).text());
		for(Element element:elements4){
			System.out.println(element.text());
		}
		
	}
}
